package com.alks.function.controller.chengKong;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.entity.exception.ServiceErrorException;
import com.alks.function.data.dto.chengKong.cost.StitchStyleProcessDto;
import com.alks.function.data.dto.chengKong.cost.pcStitchProdDetailDto;
import com.alks.function.data.request.chengKong.*;
import com.alks.function.data.request.chengKong.cost.LotNoCutPriceRequest;
import com.alks.function.data.request.chengKong.cost.UnguidedBodyRequest;
import com.alks.function.data.request.chengKong.cost.generateCutLotNoPriceRequest;
import com.alks.function.service.chengKong.PcStitchProdDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;

/**
 * ClassName: PcStitchBonusReportTempController
 * Package: com.alks.function.controller.chengKong
 * Description:
 *
 * @Author 蹇泽阳
 * @Create 2024/2/22 15:58
 * @Version 1.0
 */

@ApiRestController("/costActivity")
@Api(tags = {"成控部-成本作业-针车员工产量检核", "成控部-成本作业-针车单价建档","成控部-成本作业-针车指令单价"})
@Slf4j
public class PcStitchProdDetailController {
    @Autowired
    private PcStitchProdDetailService pcStitchProdDetailService;

    @PostMapping("/getYieldDetails")
    @ApiOperation(value = "产量明细查询",tags = "成控部-成本作业-针车员工产量检核")
    public ResponseInfo getYieldDetails(@RequestBody PcStitchProdDetailRequest request) {
        return pcStitchProdDetailService.getYieldDetailsList(request);
    }

    @PostMapping("/yieldDetailsCfm/{choose}")
    @ApiOperation(value = "产量明细检核与取消检核",tags = "成控部-成本作业-针车员工产量检核")
    public ResponseInfo yieldDetailsCfm(@RequestBody List<pcStitchProdDetailDto> request, @PathVariable String choose) {
        return pcStitchProdDetailService.changeYieldDetailsCfm(request,choose);
    }

    @PostMapping("/SelectTheTargetVehicleBody")
    @ApiOperation(value = "选择型体",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo SelectTheTargetVehicleBody(@RequestBody UnguidedBodyRequest request) {
        return pcStitchProdDetailService.SelectTheTargetVehicleBody(request);
    }

    @GetMapping("/ChooseASewingMachineColor")
    @ApiOperation(value = "选择颜色",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo ChooseASewingMachineColor(@RequestParam String styleNo) {
        return pcStitchProdDetailService.ChooseASewingMachineColor(styleNo);
    }

    @PostMapping("/NeedleTurningProcessDetails")
    @ApiOperation(value = "针车工序明细档",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo NeedleTurningProcessDetails(@RequestBody StyleNoToColorRequest request) {
        return pcStitchProdDetailService.NeedleTurningProcessDetails(request);
    }

    @WebLogger
    @PostMapping("/NeedleCarInspectionAndVerification/{choose}")
    @ApiOperation(value = "0检核/1取消检核",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo NeedleCarInspectionAndVerification(@RequestBody StyleNoToColorRequest request, @PathVariable("choose") Integer choose){
        return pcStitchProdDetailService.NeedleCarInspectionAndVerification(request,choose);
    }

    @WebLogger
    @PostMapping("/DeleteBodyColor")
    @ApiOperation(value = "删除型体颜色",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo DeleteBodyColor(@RequestBody StyleNoToColorRequest request){
        return pcStitchProdDetailService.DeleteBodyColor(request);
    }

    @WebLogger
    @PostMapping("/DeleteTheEntireShape")
    @ApiOperation(value = "整个型体删除",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo DeleteTheEntireShape(@RequestParam String styleNo){
        return pcStitchProdDetailService.DeleteTheEntireShape(styleNo);
    }

    @WebLogger
    @PostMapping("/UnguidedBodyColor")
    @ApiOperation(value = "未导型体颜色查询",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo UnguidedBodyColor(@RequestBody UnguidedBodyRequest request){
        return pcStitchProdDetailService.UnguidedBodyColor(request);
    }

    @WebLogger
    @PostMapping("/ImportNeedleSewingProcess")
    @ApiOperation(value = "导入针车工序",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo ImportNeedleSewingProcess(@RequestParam MultipartFile file,@RequestParam String style,@RequestParam String color){
        return pcStitchProdDetailService.ImportNeedleSewingProcess(file,style,color);
    }

    @WebLogger
    @PostMapping("/StitchLotNoDetail")
    @ApiOperation(value = "选择指令", tags = "成控部-成本作业-针车指令单价")
    public ResponseInfo StitchLotNoDetail(@RequestBody LotNoCutPriceRequest request) {
        return pcStitchProdDetailService.StitchLotNoDetail(request);
    }

    @WebLogger
    @PostMapping("/GenerateNeedleSewingInstructionProcessUnitPrice/{choose}")
    @ApiOperation(value = "1生成指令单价,2重新生成指令单价", tags = "成控部-成本作业-针车指令单价")
    public ResponseInfo GenerateNeedleSewingInstructionProcessUnitPrice(@RequestBody generateCutLotNoPriceRequest request, @PathVariable("choose") Integer choose) {
        return pcStitchProdDetailService.GenerateInstructionProcessUnitPrice(request,choose);
    }

    @WebLogger
    @PostMapping("/getLotNoStitchDetail")
    @ApiOperation(value = "指令查询", tags = "成控部-成本作业-针车指令单价")
    public ResponseInfo getLotNoStitchDetail(@RequestBody LotNoCutPriceRequest request) {
        return pcStitchProdDetailService.getLotNoStitchDetail(request);
    }

    @WebLogger
    @PostMapping("/getLotNoStitchDetailList")
    @ApiOperation(value = "针车型体单价明细", tags = "成控部-成本作业-针车指令单价")
    public ResponseInfo getLotNoStitchDetailList(@RequestBody LotNoRequest request) {
        return pcStitchProdDetailService.getLotNoStitchDetailList(request);
    }

    @WebLogger
    @PostMapping("/stitchStyleCopy")
    @ApiOperation(value = "复制型体", tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo stitchStyleCopy(@RequestBody List<StitchStyleProcessDto> stitchStyles, String style, String color) {
        if (stitchStyles.isEmpty()) {
            throw new ServiceErrorException("未找到需要需要拷贝的型体/颜色信息!!!");
        }
        return ResponseInfo.ok(this.pcStitchProdDetailService.copyDetail(stitchStyles, style, color));
    }

    @WebLogger
    @PostMapping("/stitchProcessCopy")
    @ApiOperation(value = "复制工序", tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo copyByProcess(@RequestBody List<StitchStyleProcessDto> stitchStyles,
                                      String style, String color, @RequestParam("seqNos") List<Integer> seqNos) {
        if (stitchStyles.isEmpty()) {
            throw new ServiceErrorException("未找到需要需要拷贝的型体/颜色信息!!!");
        }
        return ResponseInfo.ok(this.pcStitchProdDetailService.copyDetailByProcess(stitchStyles, style, color, seqNos));
    }

    @WebLogger
    @PostMapping("/stitchProcess/dealList")
    @ApiOperation(value = "可复制工序的列表查询",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo stitchProcessDealList(@RequestBody StitchProcessPageReq request) {
        return pcStitchProdDetailService.stitchProcessDealList(request);
    }

    @WebLogger
    @PostMapping("/stitchProcess/unDealList")
    @ApiOperation(value = "可复制型体的列表查询",tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo stitchProcessUnDealList(@RequestBody StitchProcessPageReq request) {
        return pcStitchProdDetailService.stitchProcessUnDealList(request);
    }

    @WebLogger
    @PostMapping("/removeProcess")
    @ApiOperation(value = "删除工序", tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo removeProcess(String style, String color, @RequestParam("seqNos") List<Integer> seqNos) {
        return pcStitchProdDetailService.removeProcess(style, color, seqNos);
    }

    @WebLogger
    @PostMapping("/saveProcess")
    @ApiOperation(value = "保存工序", tags = "成控部-成本作业-针车单价建档")
    public ResponseInfo saveProcess(@RequestBody @Valid StitchProcessSaveReq saveReq) {
        return pcStitchProdDetailService.saveProcess(saveReq);
    }

}
